home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / hpgl2ps.zip / DXY2PS.C < prev    next >
C/C++ Source or Header  |  1989-08-08  |  2KB  |  94 lines

  1. /* dxy2ps.c */
  2. #include "ext.h"
  3.  
  4. #define USAGE "Usage: dxy2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n"
  5.  
  6. main(argc, argv)
  7. int     argc;
  8. char   *argv[];
  9. {
  10.     extern int optind;
  11.     extern char *optarg;
  12.  
  13.     int     ch;                                 /* GWKMOD */
  14.     int     op;                                 /* GWKMOD */
  15.     /* GWK: char    op; */
  16.     int        MANUAL_FEED = 0;            /* DEFAULT: No manual feed */
  17.  
  18.     PaperSize = "A3";
  19.     Mode = "DXY";
  20.     plotcoords();            /* Set up plotter coordinates */
  21.  
  22.     plotinit();            /* Get other initialisations */
  23.  
  24.     while ((ch = getopt(argc, argv, "al:ms:x:y:r")) != EOF)
  25.     {
  26.     switch (ch)
  27.     {
  28.     case 'a':        /* DXY ISO A4 297mm * 210mm */
  29.         PaperSize = "A4";
  30.             plotcoords();
  31.         break;
  32.  
  33.     case 'l':
  34.         changesizes(optarg);
  35.         break;
  36.  
  37.     case 'm':
  38.         MANUAL_FEED = 1;
  39.         break;
  40.  
  41.     case 'r':
  42.         LANDSCAPE = 0;
  43.         break;
  44.  
  45.     case 's':
  46.         SCALE = atof(optarg);
  47.         if (SCALE < 0.1)
  48.         SCALE = 0.1;
  49.         else
  50.         if (SCALE > 3)
  51.         SCALE = 3;
  52.         break;
  53.  
  54.     case 'x':
  55.         xoffset = atof(optarg);
  56.         break;
  57.  
  58.     case 'y':
  59.         yoffset = atof(optarg);
  60.         break;
  61.  
  62.     default:
  63.         fprintf(stderr, "%s\n", USAGE);
  64.         exit(1);
  65.     }
  66.     }
  67.     if (optind == argc)
  68.     stream = stdin;
  69.     else if ((stream = fopen(argv[optind], "r")) == NULL)
  70.     {
  71.     fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
  72.     exit(1);
  73.     }
  74.     ps_macros();            /* Output PostScript Macros */
  75.  
  76.     viewport();        /* Scale the viewport for the plot */
  77.  
  78.     printf("/%s %g Font\n", font, char_height);
  79.  
  80.     if (MANUAL_FEED)
  81.     manualfeed(1);
  82.  
  83.     while ((op = getc(stream)) != EOF)
  84.     if ((isalpha(op) > 0) || op == '^')
  85.         dxycom(op);
  86.  
  87.     end_draw();
  88.  
  89.     printf("showpage\n");
  90.  
  91.     if (MANUAL_FEED)
  92.     manualfeed(0);
  93. }
  94.